package leetcode.hard;

public class No420 {
    public static void main(String[] args) {
        No420 no420 = new No420();
        System.out.println(no420.strongPasswordChecker("aA1"));
    }

    public boolean strongPasswordChecker(String password) {
        int fast = 0;
        int slow = 0;
        int cfcontinuous = 0;
        int sxcfcontinuous = 0;
        while (fast < password.length()) {
            if (password.charAt(fast) == password.charAt(slow)) {
                slow++;
                cfcontinuous++;
                if (cfcontinuous >= 3) {
                    return false;
                }
            }
            if (password.charAt(fast) - 1 == password.charAt(slow)) {
                slow++;
                sxcfcontinuous++;
                if (sxcfcontinuous >= 3) {
                    return false;
                }
            }
            fast++;
        }
        return true;
    }
}
